using System;
using System.Data;

using SqlHelperForCry.Common;

namespace Torch.WL.Entity
{
    [Table("Tb_Sys_Configuration", "ItemID", "Torch.WL.ConnectionString")]
	public class Tb_Sys_Configuration : Info
	{
		#region SQL column name consts 
		public const string SQLCOL_ITEMID = "ItemID";
		public const string SQLCOL_ITEMNAME = "ItemName";
		public const string SQLCOL_ITEMVALUE = "ItemValue";
		public const string SQLCOL_ITEMDESCRIPTION = "ItemDescription";
		#endregion


		#region Contructors
		/// <summary>
		/// Construct empty entity
		/// </summary>
		public Tb_Sys_Configuration () {}

		/// <summary>
		/// Construct entity by primary key, other fields will be assigned by 
		/// "Load" method.
		/// </summary>
		public Tb_Sys_Configuration (int ItemID)
		{
			this.ItemID = ItemID;
		}
		#endregion

		public override void Init (DataRow row)
		{
			ItemID = (int)ObjectType.IntTypeHelper.Read(row[SQLCOL_ITEMID]);
			ItemName = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ITEMNAME]);
			ItemValue = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ITEMVALUE]);
			ItemDescription = (string)ObjectType.StringTypeHelper.Read(row[SQLCOL_ITEMDESCRIPTION]);
		}

		#region Properties 
		#region Property <int> ItemID
		[Property("ItemID", 4, SqlDbType.Int, true, true)]
		public int ItemID 
		{
			get { return _ItemID; }
			set { _ItemID = value; }
		}
		private int _ItemID = int.MinValue;
		#endregion

		#region Property <string> ItemName
		[Property("ItemName", 100, SqlDbType.NVarChar, false, false)]
		public string ItemName 
		{
			get { return _ItemName; }
			set { _ItemName = value; }
		}
		private string _ItemName = null;
		#endregion

		#region Property <string> ItemValue
		[Property("ItemValue", 1000, SqlDbType.NVarChar, false, false)]
		public string ItemValue 
		{
			get { return _ItemValue; }
			set { _ItemValue = value; }
		}
		private string _ItemValue = null;
		#endregion

		#region Property <string> ItemDescription
		[Property("ItemDescription", 1000, SqlDbType.NVarChar, false, false)]
		public string ItemDescription 
		{
			get { return _ItemDescription; }
			set { _ItemDescription = value; }
		}
		private string _ItemDescription = null;
		#endregion
		#endregion


		public bool LoadByIdentity(int ItemID)
		{
			return DataAccess.SelectByIdentity(this, Convert.ToInt64(ItemID));
		}


		public bool DeleteByIdentity()
		{
			return DataAccess.DeleteByIdentity(this);
		}
	}
}
